#!/bin/bash
#this is a installation script for cobotsys
Installation(){
echo "\033[31m-----------------Now install gcc/g++/cmake .....-----------------\033[0m"
sudo cat > /etc/apt/sources.list<<EOF
# deb cdrom:[Ubuntu 14.04.5 LTS _Trusty Tahr_ - Release amd64 (20160803)]/ trusty main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty main restricted
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates main restricted
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty universe
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse

deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-security main restricted
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-security main restricted
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-security universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-security universe
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-security multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu trusty partner
# deb-src http://archive.canonical.com/ubuntu trusty partner

## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main
EOF
sudo apt-get update
sudo apt-get --assume-yes install gcc g++ cmake
echo "\033[31m--------------------------Please press the [ENTER] KEY !!!!------------------\033[0m"
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get --assume-yes install gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
echo "\033[31m--------------------------Now install Boost dependency .....------------------\033[0m"
sudo apt-get --assume-yes install libboost-dev libboost-date-time-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-test-dev libboost-thread-dev
sudo apt-get --assume-yes install libboost-all-dev
echo "\033[31m-----------------------Finish Boost dependency installation !!------------------------------\033[0m"
echo "\033[31m-----------------------------Now install Xeres dependency ....------------------------------\033[0m"
sudo apt-get --assume-yes install freeglut3-dev
sudo apt-get --assume-yes install libblas-dev
sudo apt-get --assume-yes install liblapack-dev
sudo apt-get --assume-yes install libxerces-c3.1
sudo apt-get --assume-yes install libxerces-c-dev
echo "\033[31m----------------------------Finish Xeres dependency installation !!---------------------------\033[0m"
echo "\033[31m----------------------------Now install Opencv dependency ....------------------------------\033[0m"
sudo apt-get --assume-yes install build-essential
sudo apt-get --assume-yes install libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get --assume-yes install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get --assume-yes install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev
sudo apt-get --assume-yes install libxvidcore-dev libx264-dev
#sudo apt-get --assume-yes install ffmpeg
echo "\033[31m-------------------------Finish Opencv dependency installation !!------------------------------\033[0m" 
}
echo "\033[31m---------------------Before Beginning to install ,please make sure the net is OK!!-----------\033[0m"
echo "\033[31m------------------Maybe the installation process will cost your some time!!------------------\033[0m"
  if [ `id -u` -eq 0 ];then 
  	echo "\033[31m---------------------Begin to check your Net!!------------------\033[0m" 
    else  
        echo "\033[31m-----------------You are not root !! please add [sudo] commond----------\033[0m "  
	exit
    fi 
#ping -c 1 8.8.8.8 > /dev/null 2>&1 
#if [ $? -eq 0  ];then 
#echo "\033[31m-------------------------The Net is ok!!----------------------------------\033[0m" 
Installation
#else  
#echo "\033[31m-----------------Sorry you can not connect the Net ,please make sure the net is OK !!----------\033[0m "
#fi   
